Fixed some background area related bugs in CellAreaScaffold, cleanup testcellarea
authorTristan Van Berkom <tristan.van.berkom@gmail.com>
Sat, 13 Nov 2010 06:09:36 +0000 (15:09 +0900)
committerTristan Van Berkom <tristan.van.berkom@gmail.com>
Sat, 13 Nov 2010 06:09:36 +0000 (15:09 +0900)
tests/cellareascaffold.c
tests/testcellarea.c

index 32a07e1f23560d806ed794bab35754a96f61d75a..f29f169ae4acfd65dba9f78c127db3023a4a7ae2 100644 (file)
@@ -499,7 +499,7 @@ cell_area_scaffold_draw (GtkWidget       *widget,
        {
          render_area.width     = data->size;
 
-         background_area.width = render_area.height;
+         background_area.width = render_area.width;
          background_area.x     = render_area.x;
 
          if (i == 0)
@@ -649,13 +649,13 @@ cell_area_scaffold_size_allocate (GtkWidget           *widget,
   /* Cache the per-row sizes and allocate the iter */
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      gtk_cell_area_iter_allocate_width (priv->iter, allocation->width);
-      get_row_sizes (scaffold, priv->row_data, allocation->width);
+      gtk_cell_area_iter_allocate_width (priv->iter, allocation->width - priv->indent);
+      get_row_sizes (scaffold, priv->row_data, allocation->width - priv->indent);
     }
   else
     {
-      gtk_cell_area_iter_allocate_height (priv->iter, allocation->height);
-      get_row_sizes (scaffold, priv->row_data, allocation->height);
+      gtk_cell_area_iter_allocate_height (priv->iter, allocation->height - priv->indent);
+      get_row_sizes (scaffold, priv->row_data, allocation->height - priv->indent);
     }
 }
 
index b933a920e720bd1b09275b4f2861ce38bb10e2a8..e0fd00edae54ee02431c58c479ee63e1df141e6e 100644 (file)
@@ -27,15 +27,11 @@ simple_list_model (void)
   gtk_list_store_set (store, &iter, 
                      SIMPLE_COLUMN_NAME, "Alice in wonderland",
                      SIMPLE_COLUMN_ICON, "gtk-execute",
-                     SIMPLE_COLUMN_DESCRIPTION, "One pill makes you smaller and the other pill makes you tall",
-                     -1);
-
-  gtk_list_store_append (store, &iter);
-  gtk_list_store_set (store, &iter, 
-                     SIMPLE_COLUMN_NAME, "Highschool Principal",
-                     SIMPLE_COLUMN_ICON, "gtk-help",
                      SIMPLE_COLUMN_DESCRIPTION, 
-                     "Will make you copy the dictionary if you dont like your math teacher",
+                     "Twas brillig, and the slithy toves "
+                     "did gyre and gimble in the wabe; "
+                     "all mimsy were the borogoves, "
+                     "and the mome raths outgrabe",
                      -1);
 
   gtk_list_store_append (store, &iter);
@@ -49,8 +45,8 @@ simple_list_model (void)
   gtk_list_store_set (store, &iter, 
                      SIMPLE_COLUMN_NAME, "George Bush",
                      SIMPLE_COLUMN_ICON, "gtk-dialog-warning",
-                     SIMPLE_COLUMN_DESCRIPTION, "Please hide your nuclear weapons when inviting "
-                     "him to dinner",
+                     SIMPLE_COLUMN_DESCRIPTION, "It's a very good question, very direct, "
+                     "and I'm not going to answer it",
                      -1);
 
   gtk_list_store_append (store, &iter);
@@ -61,6 +57,24 @@ simple_list_model (void)
                      "is tiggers are wonderful things",
                      -1);
 
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter, 
+                     SIMPLE_COLUMN_NAME, "Aleister Crowley",
+                     SIMPLE_COLUMN_ICON, "gtk-about",
+                     SIMPLE_COLUMN_DESCRIPTION, 
+                     "Thou shalt do what thou wilt shall be the whole of the law",
+                     -1);
+
+  gtk_list_store_append (store, &iter);
+  gtk_list_store_set (store, &iter, 
+                     SIMPLE_COLUMN_NAME, "Mark Twain",
+                     SIMPLE_COLUMN_ICON, "gtk-quit",
+                     SIMPLE_COLUMN_DESCRIPTION, 
+                     "Giving up smoking is the easiest thing in the world. "
+                     "I know because I've done it thousands of times.",
+                     -1);
+
+
   return (GtkTreeModel *)store;
 }
 
@@ -327,7 +341,7 @@ cell_edited (GtkCellRendererToggle *cell_renderer,
 }
 
 static GtkWidget *
-focus_scaffold (gboolean color_bg)
+focus_scaffold (gboolean color_bg, GtkCellRenderer **focus, GtkCellRenderer **sibling)
 {
   GtkTreeModel *model;
   GtkWidget *scaffold;
@@ -361,8 +375,9 @@ focus_scaffold (gboolean color_bg)
 
   if (color_bg)
     g_object_set (G_OBJECT (renderer), "cell-background", "green", NULL);
-  else
-    focus_renderer = renderer;
+
+  if (focus)
+    *focus = renderer;
 
   g_signal_connect (G_OBJECT (renderer), "toggled",
                    G_CALLBACK (cell_toggled), scaffold);
@@ -375,8 +390,9 @@ focus_scaffold (gboolean color_bg)
 
   if (color_bg)
     g_object_set (G_OBJECT (renderer), "cell-background", "blue", NULL);
-  else
-    sibling_renderer = renderer;
+
+  if (sibling)
+    *sibling = renderer;
 
   gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area), renderer, FALSE, TRUE);
   gtk_cell_area_attribute_connect (area, renderer, "text", FOCUS_COLUMN_STATIC_TEXT);
@@ -414,7 +430,7 @@ focus_cell_area (void)
 
   gtk_window_set_title (GTK_WINDOW (window), "Focus and editable cells");
 
-  scaffold = focus_scaffold (FALSE);
+  scaffold = focus_scaffold (FALSE, &focus_renderer, &sibling_renderer);
 
   frame = gtk_frame_new (NULL);
   gtk_widget_show (frame);
@@ -535,7 +551,7 @@ background_area (void)
   gtk_widget_show (label);
   gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
 
-  scaffold = focus_scaffold (TRUE);
+  scaffold = focus_scaffold (TRUE, NULL, NULL);
 
   frame = gtk_frame_new (NULL);
   gtk_widget_show (frame);